package com.webService;



import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.xmlpull.v1.XmlPullParserException;

public class Webservice {
	public String METHOD_NAME = null;
	public String SOAP_ACTION ="http://fruitMap.com/"+METHOD_NAME;
	public String NAMESPACE ="http://fruitMap.com/";
	public static final String URL ="http://10.0.2.2:8080/fruitMapWSService/fruitMapWS?WSDL";
	
	//http://localhost:8080/fruitMapWSService/fruitMapWS?WSDL
    
	public SoapObject getRequest(){
		return new SoapObject(NAMESPACE, METHOD_NAME);
	}
	public SoapSerializationEnvelope setRequestAndGetEnvilop(SoapObject request ) throws IOException, XmlPullParserException{
	
	
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
   	    envelope.setOutputSoapObject(request);
        AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
   	    androidHttpTransport.call(SOAP_ACTION,envelope);
   	    return envelope;
	
	}
	public SoapPrimitive getPrimitive(SoapSerializationEnvelope envelope) throws SoapFault{
		return (SoapPrimitive) envelope.getResponse();
	}
	public SoapObject getAll(SoapSerializationEnvelope envelope){
		return (SoapObject) envelope.bodyIn;
	}
}
